home *** CD-ROM | disk | FTP | other *** search
- #include "bbs.h"
-
- extern int LineCount;
- extern char Command[6][40];
- extern char Conference_Location[];
- extern BOOL GET_BIT(int bitnum);
- int View_A_File(void)
- {
- int stat,x;
- char path[255],final[255],Fn[100],clog[100];
- FILE *f,*ft=NULL;
- int drivenum=1;
- char cmt[100];
- gnsflag=0;
- LineCount=0;
- AEPutStr("\r\n");
- if(MaxDirs==0)
- {
- AEPutStr("No files available in this conference.\r\n\r\n");
- return(FAILURE);
- }
-
- stat=CommandSplit();
- gnsflag=CheckForNS(Command[stat-1]);
-
- if(stat>1) { strcpy(Fn,Command[1]); goto Some; }
- AEPutStr("Enter filename of file to view? ");
- stat=LineInput("",Fn,40,KEYBOARD_TIMEOUT);
- if(stat<0) { return(NO_CARRIER); }
- if(strlen(Fn)==0) { AEPutStr("\r\n"); return(SUCCESS); }
-
-
- Some:
- strcpy(path,Conference_Location);
- if(path[strlen(path)-1]=='/') path[strlen(path)-1]='\0';
- goto SkipMe;
- SkipToIt:
- sprintf(GSTR3,"File %s not found.\r\n\r\n",path);
- AEPutStr(GSTR3);
- return(FAILURE);
-
- SkipMe:
-
- if(GET_BIT(ACS_SYSOP_VIEW)&&(Command[0][1]=='S'||Command[0][1]=='s'))
- {
- if(FindAssign(Fn)) { strcpy(path,Fn); goto SkipToIt; }
- f = fopen(Fn,"r");
- if(f==NULL)
- {
- strcpy(path,Fn);
- goto SkipToIt;
- }
- fclose(f);
- sprintf(GSTR3,"\tSysopView %s\n",Fn);
- CallersLog(GSTR3);
- strcpy(final,Fn);
- goto Skipit;
- }
-
- for(x=0;x<strlen(Fn);++x)
- {
- if(Fn[x]==':' || Fn[x]=='/' || Fn[x]=='*' || Fn[x]=='@')
- {
- AEPutStr("You may not include any special symbols\r\n\r\n");
- return(FAILURE);
- }
- }
-
-
- sprintf(path,"DLPATH.%d",drivenum++);
- while(GetFromConf(CN-1,path,path))
- {
- strcpy(final,path);
- strcat(final,Fn);
- Skipit:
- ft = fopen(final,"r");
- if(ft!=NULL)
- {
- /**************** ADDED SECURITY FOR VS ******************
- CODE REVISION BY JOSEPH HODGE
- *********************************************************/
- strcpy(cmt,GetFileComment(final));
- if(!strnicmp(cmt,"Restricted",10))
- {
- AEPutStr("\n\rAttempt to read RESTRICTED file denied\n\r");
- AEPutStr("Updating Callerslog\r\n");
- sprintf(clog,"\t\tAttempt to read RESTRICTED file [%s]\n",Fn);
- CallersLog(clog);
- fclose(ft); return(FAILURE);
- }
- while(fgets(GSTR3,1000,ft)!=NULL)
- {
- GSTR3[1000]='\0';
- if(GSTR3[0]>128||GSTR3[1]>128||GSTR3[2]>128)
- {
- fclose(ft);
- AEPutStr("\r\nThis file is not a text file.\r\n\r\n");
- return(FAILURE);
- }
- AEPutStr(GSTR3);
- AEPutStr("\r");
- if(stat=CheckForPause())
- {
- fclose(ft);
- AEPutStr("\r\n");
- return(stat);
- }
- if(CheckInput())
- {
- stat=ReadChar(1L);
- switch(stat)
- {
- case '\023': /* Pause */
- stat=ReadChar(KEYBOARD_TIMEOUT);
- if(stat<0)
- {
- fclose(ft);
- return(NO_CARRIER);
- }
- break;
- case '\003': /* ^C */
- AEPutStr("**Break\r\n\r\n");
- fclose(ft);
- return(FAILURE);
- }
- }
- }
- fclose(ft);
- AEPutStr("\r\n\r\n");
- return(SUCCESS);
- }
- if(ft!=NULL) break;
- sprintf(path,"DLPATH.%d",drivenum++);
-
- }
- AEPutStr("File not found.\r\n\r\n");
- return(SUCCESS);
- }
-